#ifndef CERTMGRWINDOW_H
#define CERTMGRWINDOW_H

#include <QMainWindow>

#include "certmgr/certtablemodel.h"

class CertManager;

namespace Ui {
class CertMgrWindow;
}

class CertInfoWindow;

class CertMgrWindow : public QMainWindow {
  Q_OBJECT

public:
  explicit CertMgrWindow(QWidget *parent = nullptr);
  ~CertMgrWindow();


private:
  void InitCertManager();
  void InitUI();
  void InitDirectoryTree();
  void FulfillCertTree();
  void ShowOption();
  void FindCert(const QString& keyword);
  void VerifyCert(const QString& path);
  void ExportCert(const QString& path);

  void SetupTree();
  void SetupAction();

  void ShowCert();
  void ImportCertFile();

  void Sort(SortType type);

  void ShowCertWindow(X509* cert);

private:
  Ui::CertMgrWindow *ui;
  CertManager* cert_manager_ = nullptr;
  CertTableModel* cert_table_model_ = nullptr;
  SortType sort_type_ = SortType::ByKeyUsage;
  CertInfoWindow* cert_info_window_ = nullptr;
};


#endif // CERTMGRWINDOW_H
